open Graph

module Utils (G: Sig.G)
= struct
	
	let (|>) x y = y x
	module N = Oper.Neighbourhood(G)
	open N.Vertex_Set
	
	(*it is used for testing*)
	let rec printAllList = function
		| [] -> Printf.printf "\n";
		| x::xs -> 
			Printf.printf "%i  " (List.length x);
			printAllList xs
	
	(*give us half of the list*)
  let halfOfList list = 
  	(*give us number items of the list*)
    	let rec subList list number =
      	if number = 0 then []
      	else match list with
        	| x::xs -> x::(number-1 |> subList xs)
        	| [] -> []
  	in
		subList list ((List.length list)/2)
	(*true - if *)
	let isThereNoEdge graph vertecies = 
    G.fold_edges 
			(fun src dst bool -> ((List.mem src vertecies)&&(List.mem dst vertecies))||bool) 
			graph 
			false 
		|> not
	
	let rec removeAll from = function
		| [] -> N.Vertex_Set.elements from
		| x::xs -> removeAll (remove x from) xs
	
	let allVertecies graph = G.fold_vertex (fun v vs -> add v vs) graph empty
	
	let isCover proposition graph =
		removeAll (allVertecies graph) proposition |> isThereNoEdge graph

end